package com.idroc.coelacanth.core.membership;

import java.io.Serializable;

@SuppressWarnings("serial")
public class Endpoint implements Serializable {  
	
	private String host = null;
	private int port = -1;
	
	public Endpoint() {}
	
	public Endpoint(String h, int p) {
		this.host = h;
		this.port = p;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	@Override
	public boolean equals(Object obj) {
		
		if (obj instanceof Endpoint) {
			Endpoint ep = (Endpoint)obj;
			return ep.host.equals(this.host) && ep.port == this.port;
		} 
		return false;
	}

	@Override
	public int hashCode() {
		
		return this.host.hashCode() + 37 * this.port + this.port;
	}

	@Override
	public String toString() {

		return "Endpoint@" + this.host + ":" + this.port;
	}
}
